package com.coollang.smartbra.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.coollang.smartbra.R;
import com.coollang.smartbra.model.SportPlanModel;
import com.coollang.smartbra.utils.ActionTypeParse;

import java.util.List;

/**
 * @author : Timmy
 * @date : 2018/1/17
 */
public class SportPlanDataAdapter extends BaseQuickAdapter<SportPlanModel.DataBean.ActionDataBean, BaseViewHolder> {

    public SportPlanDataAdapter(@Nullable List<SportPlanModel.DataBean.ActionDataBean> data) {
        super(R.layout.item_sportplan, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SportPlanModel.DataBean.ActionDataBean item) {
        helper.setText(R.id.tv_sport_name, item.getSportName());
        int count = item.getCount();
        int finish = (int) item.getFinish();
        int sportCode = item.getSportcode();

        int actionPlanDrawable = ActionTypeParse.getActionPlanDrawable(sportCode);
        helper.setBackgroundRes(R.id.imageview, actionPlanDrawable);

        helper.setText(R.id.tv_sport_plan, finish + "/" + count);
        int layoutPosition = helper.getLayoutPosition();
        if (layoutPosition - 1 == getItemCount()) {
            helper.setVisible(R.id.view_line, false);
        }
    }
}
